package agents.interaction;

import game.constants.ReferenceAgent;
import game.constants.ReferenceSpecialFeature;
import interfaces.impl.HumanInteraction;

import java.util.ArrayList;

import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import actions.ActionModifySpetialFeature;
import extra.ObjectId;

public class InteractionAttackObject extends HumanInteraction{
	
	ObjectId objectToAttack;
	
	SpetialFeature objectIdToAttack;
	SpetialFeature objectIdToFollow;
	
	ActionModifySpetialFeature actionModifyTargetToAttack;
	ActionModifySpetialFeature actionModifyTargetToFollow;
	
	int cont =0;

	@Override
	public void initializeParametersList() {
		
		listParameter= new ArrayList();
		
		objectToAttack = new ObjectId();
		listParameter.add(objectToAttack);
		
	}

	@Override
	public void initializeActionList() {
		actionModifyTargetToAttack= new ActionModifySpetialFeature();
		listActions.add(actionModifyTargetToAttack);
		
		actionModifyTargetToFollow= new ActionModifySpetialFeature();
		listActions.add(actionModifyTargetToFollow);
		
	}

	@Override
	public void initializeSpecialFeatures() {
		
		objectIdToAttack= new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_TARGET_ID_TO_ATTACK);
		listFeatures.add(objectIdToAttack);
		
	}

	@Override
	public void initializeName() {
		name="Attack Object";
		
	}

	@Override
	public void initializeId() {
		this.id=ReferenceAgent.AGENT_HUMAN_INTERACTION_ATTACK_OBJECT;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {

		universe.desactivateAllHumanInteractions(object);
		
				actionModifyTargetToFollow.setSource(object);
				actionModifyTargetToFollow.setTarget(object);
				actionModifyTargetToFollow.setFeatureId(ReferenceSpecialFeature.SPETIAL_FEATURE_TARGET_ID_TO_FOLLOW);
				actionModifyTargetToFollow.setValue(objectToAttack.getObjectId());
				universe.setAction(actionModifyTargetToFollow);


		
				actionModifyTargetToAttack.setSource(object);
				actionModifyTargetToAttack.setTarget(object);
				actionModifyTargetToAttack.setFeatureId(ReferenceSpecialFeature.SPETIAL_FEATURE_TARGET_ID_TO_ATTACK);
				actionModifyTargetToAttack.setValue(objectToAttack.getObjectId());
				
				System.out.println("El objeto a atacqr es "+objectToAttack.getObjectId());
				
				universe.setAction(actionModifyTargetToAttack);
				isActive =false;
				
	}
	
	

}
